package com.itheima.health.dao;

import com.github.pagehelper.Page;
import com.itheima.health.pojo.Setmeal;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetmealDao {
    //分页查询
    Page<Setmeal> page(String queryString);

    //新增套餐
    void insert(Setmeal setmeal);

    //新增套餐检查组关联表
    void insertBatch(Integer setId, Integer[] checkgroupIds);

    //删除关联表中的数据
    @Delete("delete from t_setmeal_checkgroup where setmeal_id = #{id} ")
    void deleteById(Integer id);

    //删除套餐
    @Delete("delete from t_setmeal where id = #{id} ")
    void delete(Integer id);

    //回显套餐
    @Select("select * from t_setmeal where id= #{id} ")
    Setmeal findById(Integer id);

    //回显检查组
    @Select("select checkgroup_id from t_setmeal_checkgroup where setmeal_id = #{id} ")
    List<Integer> showChegroup(Integer id);

    //修改原有信息
    void updateById(Setmeal set);

    //根据套餐id删除检查组信息
    @Delete("delete  from t_setmeal_checkgroup where setmeal_id = #{id} ")
    void deleteBySetId(Integer id);
}
